package 测试;

import java.util.Scanner;

public class Test2 {
    //从第一个字符串中删除第二个字符串中所有的字符
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入A=");
            StringBuffer A=new StringBuffer(scanner.nextLine());
        System.out.println("请输入B=");
            StringBuffer B=new StringBuffer(scanner.nextLine());
           //取B的字符,遍历A字符串,如果有则得到下标,进行删除,如果遍历完了都没得到下标,则++
           int lengthB=B.length();
            for (int i = 0; i < lengthB; i++) {
                //使用index,index搜索不到则会返回-1
             while (true){
                 int index=A.indexOf(String.valueOf(B.charAt(i)));
                 if(index==-1){
                     break;
                 }else{
                     A.deleteCharAt(index);
                 }
             }
            }
            System.out.println(A);
    }
}
